package com.bt.lms.ui.page.sys.role;

import com.alibaba.fastjson.JSONObject;
import com.bt.lms.constants.BOConstant;
import com.bt.lms.constants.PageConstant;
import com.bt.lms.constants.SysBizTypeConstant;
import com.bt.lms.entity.Role;
import com.bt.lms.entity.User;
import com.bt.lms.entity.page.Page;
import com.bt.lms.main.BotLmsApp;
import com.bt.lms.network.msg.ReqMsg;
import com.bt.lms.network.msg.RespMsg;
import com.bt.lms.ui.page.common.PageLocation;
import com.bt.lms.ui.page.sys.ServerInfo;
import com.bt.lms.ui.page.sys.page.paging.PagePaging;
import com.bt.lms.ui.page.sys.style.LabStyle;
import com.bt.lms.ui.page.sys.utils.*;
import com.bt.lms.ui.page.sys.vo.UserListInfo;
import com.bt.lms.ui.page.sys.vo.UserTableViewVo;
import com.bt.lms.ui.vo.PageSkipInfo;
import javafx.collections.FXCollections;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.util.Callback;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;


/**
 * 用户列表（拥有此角色的用户）
 *
 * @author 徐大永
 */
public class PageUserList extends VBox {

    /**
     * 当前界面
     */
    private final PageUserList pageUserList = this;

    //界面
    //基本区（位置信息，说明信息）
    //列表区
    /**
     * 用户列表
     */
    private TableView<UserListInfo> userTV;

    /**
     * 分页区
     */
    private PagePaging pagePaging;

    //-------------事件

    /**
     * 分页事件
     */
    private final PageAction pageAction;

    //-----------数据
    /**
     * 用户信息
     */
    private final Page<User> page = new Page<>();

    //---------------自身需要的属性
    /**
     * 当前的角色
     */
    private final Role role;

    /**
     * 当前的角色
     */
    private final PageSkipInfo pageSkipInfo;

    /**
     * 源页
     */
    private final Integer srcCurrent;

    /**
     * 构建界面
     *
     * @param pageSkipInfo 界面跳转信息
     * @param role         角色
     * @param srcPage   源页
     */
    public PageUserList(PageSkipInfo pageSkipInfo, Role role, Integer srcPage) {

        //维护
        this.pageSkipInfo = pageSkipInfo;
        this.role = role;
        this.srcCurrent = srcPage;
        //维护分页事件
        pageAction = new PageAction();
        pageAction.setPageUserList(this);

        //大小
        this.setPrefWidth(BotLmsApp.PER_WIGHT);
        this.setSpacing(20);

        //1.界面
        uiInit();

        //2.加载数据并渲染
        loadAndRenderPage();

    }

    /**
     * 界面初始化
     */
    private void uiInit() {

        //组件
        //定位
        PageLocation pageLocation = new PageLocation("系统管理", "角色权限管理", "查看角色下用户");

        //说明
        Label explainLab = new Label("查看" + role.getName() + "角色用户");

        //列表
        setUserTV(new TableView<>());
        //列表初始化
        userTVInit();

        //分页区域
        pagePaging = new PagePaging(this, this.getClass());

        //控制组件
        HBox operateHBox = new HBox();
        operateHBox.setAlignment(Pos.CENTER);

        //返回按钮
        Button cancelBtn = new MyButton("返回");
        operateHBox.getChildren().add(cancelBtn);
        //事件
        CancelAction cancelAction = new CancelAction();
        cancelAction.setPageSkipInfo(pageSkipInfo);
        cancelAction.setSrcCurrent(srcCurrent);
        cancelBtn.setOnAction(cancelAction);

        //添加进组件
        this.getChildren().addAll(pageLocation, explainLab, userTV, pagePaging, operateHBox);

    }

    /**
     * 列表初始化
     */
    private void userTVInit() {

        TableView<UserListInfo> userTV = getUserTV();

        //1.列头
        TableColumn<UserListInfo, String> accountNumberTC = new TableColumn<>("账号");
        TableColumn<UserListInfo, String> nameTC = new TableColumn<>("用户姓名");
        TableColumn<UserListInfo, List<Role>> rolesTC = new TableColumn<>("角色");
        TableColumn<UserListInfo, String> creatorTC = new TableColumn<>("创建人");
        TableColumn<UserListInfo, LocalDateTime> creationTimeTC = new TableColumn<>("创建时间");
        TableColumn<UserListInfo, LocalDateTime> loginTimeTC = new TableColumn<>("最近登录时间");
        TableColumn<UserListInfo, Integer> statusTC = new TableColumn<>("状态");
        TableColumn<UserListInfo, UserTableViewVo> operateTC = new TableColumn<>("操作");

        //2.列表添加列头
        userTV.getColumns().addAll(accountNumberTC, nameTC, rolesTC, creatorTC, creationTimeTC, loginTimeTC, statusTC, operateTC);

        //3.映射
        accountNumberTC.setCellValueFactory(new PropertyValueFactory<>("accountNumber"));
        nameTC.setCellValueFactory(new PropertyValueFactory<>("name"));
        rolesTC.setCellValueFactory(new PropertyValueFactory<>("roles"));
        creatorTC.setCellValueFactory(new PropertyValueFactory<>("createdName"));
        creationTimeTC.setCellValueFactory(new PropertyValueFactory<>("createdTime"));
        loginTimeTC.setCellValueFactory(new PropertyValueFactory<>("logInTime"));
        statusTC.setCellValueFactory(new PropertyValueFactory<>("status"));
        operateTC.setCellValueFactory(new PropertyValueFactory<>("userTableViewVo"));

        //4.自定义渲染
        customVRay(rolesTC, creationTimeTC, loginTimeTC, statusTC, operateTC);

    }

    /**
     * 自定义渲染
     *
     * @param rolesTC        角色列
     * @param creationTimeTC 创建时间列
     * @param loginTimeTC    最近一次登录时间列
     * @param statusTC       状态列
     * @param operateTC      操作列
     */
    private void customVRay(TableColumn<UserListInfo, List<Role>> rolesTC, TableColumn<UserListInfo, LocalDateTime> creationTimeTC
            , TableColumn<UserListInfo, LocalDateTime> loginTimeTC, TableColumn<UserListInfo, Integer> statusTC
            , TableColumn<UserListInfo, UserTableViewVo> operateTC) {

        //角色列
        rolesTC.setCellFactory(new Callback<TableColumn<UserListInfo, List<Role>>, TableCell<UserListInfo, List<Role>>>() {
            @Override
            public TableCell<UserListInfo, List<Role>> call(TableColumn<UserListInfo, List<Role>> param) {
                return new TableCell<UserListInfo, List<Role>>() {
                    @Override
                    protected void updateItem(List<Role> roles, boolean empty) {
                        super.updateItem(roles, empty);
                        if (roles != null) {
                            StringBuilder nameSB = new StringBuilder();
                            for (int i = 0; i < roles.size(); i++) {
                                String name = roles.get(i).getName();
                                if (i == 0)
                                    nameSB.append(name);
                                else
                                    nameSB.append(",").append(name);

                                String nameStr = nameSB.toString();
                                Label nameLab = new Label(nameStr);
                                setGraphic(nameLab);
                            }
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        //创建时间列
        creationTimeTC.setCellFactory(new Callback<TableColumn<UserListInfo, LocalDateTime>, TableCell<UserListInfo, LocalDateTime>>() {
            @Override
            public TableCell<UserListInfo, LocalDateTime> call(TableColumn<UserListInfo, LocalDateTime> param) {
                return new TableCell<UserListInfo, LocalDateTime>() {
                    @Override
                    protected void updateItem(LocalDateTime loginTimeLDT, boolean empty) {
                        super.updateItem(loginTimeLDT, empty);
                        if (loginTimeLDT != null) {
                            LocalDate loginTimeLD = loginTimeLDT.toLocalDate();
                            String loginTimeStr = loginTimeLD.toString();
                            Label loginTimeLab = new Label(loginTimeStr);
                            setGraphic(loginTimeLab);
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        //最近一次登陆时间列
        loginTimeTC.setCellFactory(new Callback<TableColumn<UserListInfo, LocalDateTime>, TableCell<UserListInfo, LocalDateTime>>() {
            @Override
            public TableCell<UserListInfo, LocalDateTime> call(TableColumn<UserListInfo, LocalDateTime> param) {
                return new TableCell<UserListInfo, LocalDateTime>() {
                    @Override
                    protected void updateItem(LocalDateTime loginTimeLDT, boolean empty) {
                        super.updateItem(loginTimeLDT, empty);
                        if (loginTimeLDT != null) {
                            LocalDate loginTimeLD = loginTimeLDT.toLocalDate();
                            String loginTimeStr = loginTimeLD.toString();
                            Label loginTimeLab = new Label(loginTimeStr);
                            setGraphic(loginTimeLab);
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        //最近一次登陆时间列
        loginTimeTC.setCellFactory(new Callback<TableColumn<UserListInfo, LocalDateTime>, TableCell<UserListInfo, LocalDateTime>>() {
            @Override
            public TableCell<UserListInfo, LocalDateTime> call(TableColumn<UserListInfo, LocalDateTime> param) {
                return new TableCell<UserListInfo, LocalDateTime>() {
                    @Override
                    protected void updateItem(LocalDateTime loginTimeLDT, boolean empty) {
                        super.updateItem(loginTimeLDT, empty);
                        if (loginTimeLDT != null) {
                            LocalDate loginTimeLD = loginTimeLDT.toLocalDate();
                            String loginTimeStr = loginTimeLD.toString();
                            Label loginTimeLab = new Label(loginTimeStr);
                            setGraphic(loginTimeLab);
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        //状态列
        statusTC.setCellFactory(new Callback<TableColumn<UserListInfo, Integer>, TableCell<UserListInfo, Integer>>() {
            @Override
            public TableCell<UserListInfo, Integer> call(TableColumn<UserListInfo, Integer> param) {
                return new TableCell<UserListInfo, Integer>() {
                    @Override
                    protected void updateItem(Integer status, boolean empty) {
                        super.updateItem(status, empty);
                        if (status != null) {
                            Label statusLab = null;
                            if (status.equals(BOConstant.USER_STATUS_START)) {
                                statusLab = new Label("启用");
                                LabStyle.status(statusLab, LabStyle.OPEN);
                            } else if (status.equals(BOConstant.USER_STATUS_STOP)) {
                                statusLab = new Label("停用");
                                LabStyle.status(statusLab, LabStyle.STOP);
                            }
                            setGraphic(statusLab);
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

        //操作列d
        operateTC.setCellFactory(new Callback<TableColumn<UserListInfo, UserTableViewVo>, TableCell<UserListInfo, UserTableViewVo>>() {
            @Override
            public TableCell<UserListInfo, UserTableViewVo> call(TableColumn<UserListInfo, UserTableViewVo> param) {
                return new TableCell<UserListInfo, UserTableViewVo>() {
                    @Override
                    protected void updateItem(UserTableViewVo userTableViewVo, boolean empty) {
                        super.updateItem(userTableViewVo, empty);
                        if (userTableViewVo != null) {
                            MyLabel loseTrackLab = new MyLabel("取消用户与角色关联");
                            //样式
                            LabStyle.interaction(loseTrackLab);
                            //事件
                            LoseTrackUserAndRole loseTrackUserAndRole = new LoseTrackUserAndRole(userTableViewVo, role);
                            loseTrackUserAndRole.setPageUserList(pageUserList);//维护属性
                            loseTrackLab.setOnMouseClicked(loseTrackUserAndRole);
                            setGraphic(loseTrackLab);
                        }else {
                            setGraphic(null);
                        }
                    }
                };
            }
        });

    }

    /**
     * 加载数据并渲染
     */
    private void loadAndRenderPage() {

        //1.确认页数
        Page<User> userPage = new Page<>();
        if (this.page != null) {
            userPage.setSize(getPage().getSize());
            userPage.setCurrent(getPage().getCurrent());
        }
        //2.请求数据
        Page<User> userPageData = queryUserFromRole(userPage, role.getId());
        //3.数据处理
        List<User> records = null;
        if (userPageData != null) {
            records = userPageData.getRecords();
        }
        List<UserListInfo> userListInfos = new ArrayList<>();
        if (records != null) {
            for (Object obj : records) {
                UserListInfo userListInfo = JSONObject.parseObject(obj.toString(), UserListInfo.class);
                userListInfos.add(userListInfo);

                UserTableViewVo userTableViewVo = new UserTableViewVo();
                userTableViewVo.setId(userListInfo.getId());
                userTableViewVo.setStatus(userListInfo.getStatus());
                userTableViewVo.setAccountNumber(userListInfo.getAccountNumber());
                userTableViewVo.setName(userListInfo.getName());
                userListInfo.setUserTableViewVo(userTableViewVo);
            }
        } else {
            errorHint("未获取到数据，请检查网络连接，或联系客服。");//错误提示
        }
        //4.渲染
        TableView<UserListInfo> userTV = getUserTV();
        userTV.setItems(FXCollections.observableArrayList(userListInfos));

        //维护分页区数据
        if (userPageData != null) {
            Long total = userPageData.getTotal();
            Integer size = userPageData.getSize();//每页数
            if (page != null) {
                page.setTotal(total);
                page.setSize(size);
            }
            long sumPage = total % size == 0 ? total / size : total / size + 1;//总页数
            pagePaging.setSumPage(sumPage);
            //加载数据并渲染（分页按钮）
            pagePaging.loadAndRenderPage();
        }
    }

    /**
     * 错误提示
     */
    private void errorHint(String hint) {

        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("错误");
        alert.setHeaderText(null);
        alert.setContentText(hint);
        alert.showAndWait();
    }

    /**
     * 请求数据（查询角色用户）
     *
     * @param userPage 分页模型(用户)
     * @param roleId   角色id
     * @return 查询到的数据
     */
    private Page<User> queryUserFromRole(Page<User> userPage, Long roleId) {

        //1.处理数据
        List dataS = new ArrayList();
        dataS.add(userPage);
        dataS.add(roleId);
        //2.组包
        ReqMsg reqMsg = Encode.encodeToMsg(dataS, SysBizTypeConstant.USER_ROLE_USER_DETAILS);
        byte[] reqBytes = reqMsg.toBytes();
        try {
            //3.组网
            Socket socket = new Socket(ServerInfo.IP, ServerInfo.PORT);
            //4.发送
            OutputStream out = socket.getOutputStream();
            out.write(reqBytes);
            out.flush();
            //5.响应
            //5.1 读取
            InputStream in = socket.getInputStream();
            List<byte[]> respBytes = NetWorkUtils.receive(in);
            //5.2 关闭资源
            in.close();
            out.close();
            socket.close();

            //5.3 处理结果
            byte[] respByte = ArrayUtils.joinBytes(respBytes);
            RespMsg respMsg = RespMsg.toRespMsg(respByte);
            //处理响应消息
            if (respMsg.getStatus().equals(RespMsg.NETWORK_STATUS_NORMAL)) {
                String data = respMsg.getData();
                return JSONObject.parseObject(data, Page.class);
            } else {
                return null;
            }
        } catch (IOException e) {
            return null;
        }
    }

    public PagePaging getPagePaging() {
        return pagePaging;
    }

    public TableView<UserListInfo> getUserTV() {
        return userTV;
    }

    public void setUserTV(TableView<UserListInfo> userTV) {
        this.userTV = userTV;
    }

    public PageAction getPageAction() {
        return pageAction;
    }

    public Page<User> getPage() {
        return page;
    }

    /**
     * 分页事件
     */
    private static class PageAction implements EventHandler {

        /**
         * 当前事件针对的界面
         */
        private PageUserList pageUserList;

        @Override
        public void handle(Event event) {

            //页码
            Page<User> page = getPageUserList().getPage();

            //总页数
            Long total = page.getTotal();
            Integer size = page.getSize();
            long prePageCon = total / size;
            long pageCon = prePageCon == 0 ? prePageCon : prePageCon + 1;

            //获取点击的按钮
            try {
                MyButton btn = (MyButton) event.getSource();
                String valueBtnStr = btn.getText();
                if (valueBtnStr.matches("[0-9]+")) {
                    //是数字的时候
                    page.setCurrent(Integer.parseInt(valueBtnStr));
                    //重新渲染
                    getPageUserList().loadAndRenderPage();
                } else {
                    //是文本的情况
                    //获取 输入框输入的内容
                    TextField pageNumberTF = getPageUserList().getPagePaging().getPageNumberTF();
                    String valueTFStr = pageNumberTF.getText();
                    if (valueTFStr.matches("[0-9]+")) {//判断输入的是否是数字
                        int pageInt = Integer.parseInt(valueBtnStr);
                        if (pageInt > 0 && pageInt <= pageCon) {
                            page.setCurrent(pageInt);
                            //重新渲染
                            getPageUserList().loadAndRenderPage();
                        }
                    } else {
                        //弹窗提示
                        getPageUserList().errorHint("请输入存在的页码。");
                    }
                }
            } catch (Exception e) {
                MyLabel lab = (MyLabel) event.getSource();
                String valueLabStr = lab.getText();

                switch (valueLabStr) {
                    case PagePaging.FIRST_STR: {

                        if (page.getCurrent() != 1) {//不在首页
                            //维护页码
                            page.setCurrent(1);
                            //重新渲染
                            pageUserList.loadAndRenderPage();
                        }

                        break;
                    }
                    case PagePaging.LAST_STR: {

                        if (page.getCurrent() > 1) {//还有上一页
                            page.setCurrent(page.getCurrent() - 1);
                            pageUserList.loadAndRenderPage();
                        }
                        break;
                    }
                    case PagePaging.NEXT_STR: {

                        if (page.getCurrent() < pageCon) {//还有下一页
                            page.setCurrent(page.getCurrent() + 1);
                            pageUserList.loadAndRenderPage();
                        }
                        break;
                    }
                    case PagePaging.FINALLY_STR: {

                        if (page.getCurrent() != pageCon) {//不在尾页
                            page.setCurrent((int) pageCon);
                            pageUserList.loadAndRenderPage();
                        }
                        break;
                    }
                }
            }
        }

        public PageUserList getPageUserList() {
            return pageUserList;
        }

        public void setPageUserList(PageUserList pageUserList) {
            this.pageUserList = pageUserList;
        }
    }

    /**
     * 失去联系事件
     */
    private static class LoseTrackUserAndRole implements EventHandler<MouseEvent> {

        /**
         * 用户信息
         */
        private final UserTableViewVo userTableViewVo;

        /**
         * 角色信息
         */
        private final Role role;

        /**
         * 当前事件针对的界面
         */
        private PageUserList pageUserList;

        /**
         * 构建事件
         *
         * @param userTableViewVo 用户信息
         * @param role            角色信息
         */
        public LoseTrackUserAndRole(UserTableViewVo userTableViewVo, Role role) {
            this.userTableViewVo = userTableViewVo;
            this.role = role;
        }

        @Override
        public void handle(MouseEvent event) {

            //弹窗确认是否取消联系
            Alert alert = new Alert(Alert.AlertType.NONE);
            alert.setHeaderText(null);//自带提示
            alert.setTitle("取消联系");
            LoseTrackPage loseTrackPage = new LoseTrackPage(alert, userTableViewVo, role);
            loseTrackPage.setLoseTrackUserAndRole(this);
            alert.setGraphic(loseTrackPage);//内容显示
            alert.getDialogPane().setMaxWidth(PageConstant.DELETE_WIGHT);//宽度
            alert.getDialogPane().setMaxHeight(PageConstant.DELETE_HEIGHT);////高度
            alert.showAndWait();
        }

        /**
         * 错误提示
         */
        private void errorHint() {

            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("错误");
            alert.setHeaderText(null);
            alert.setContentText("请求失败，请检查网络连接，或联系客服。");
            alert.showAndWait();
        }

        /**
         * 失去联系界面
         */
        private static class LoseTrackPage extends VBox {

            /**
             * 对应事件
             */
            private LoseTrackUserAndRole loseTrackUserAndRole;

            /**
             * 构建界面
             *
             * @param alert           弹窗
             * @param userTableViewVo 用户列表VO
             * @param role            当前角色
             */
            public LoseTrackPage(Alert alert, UserTableViewVo userTableViewVo, Role role) {
                //布局
                this.setSpacing(PageConstant.PANE_TINY_SPACING);
                this.setAlignment(Pos.CENTER);
                this.setPadding(new Insets(PageConstant.NODE_TINY_WIGHT));
                this.setPrefWidth(PageConstant.DELETE_WIGHT);
                this.setPrefHeight(PageConstant.DELETE_HEIGHT);

                String userName = userTableViewVo.getName();
                String hint = "是否取消" + role.getName() + "与" + userName + "的联系";
                //组件
                Label label = new Label(hint);
                label.setPrefWidth(PageConstant.NODE_BIG_WIGHT);
                label.setAlignment(Pos.CENTER);
                this.getChildren().addAll(label);

                HBox hBox = new HBox();
                hBox.setSpacing(PageConstant.PANE_SPACING);
                hBox.setAlignment(Pos.CENTER);
                this.getChildren().add(hBox);

                Button confirm = new Button("确认");
                hBox.getChildren().add(confirm);
                confirm.setOnAction(event -> {

                    ButtonType buttonType = new ButtonType("");
                    alert.getDialogPane().getButtonTypes().add(buttonType);
                    alert.close();

                    //1.1 处理数据 角色带用户
                    Long userId = userTableViewVo.getId();
                    List<User> users = new ArrayList<>();
                    User user = new User();
                    user.setId(userId);
                    users.add(user);
                    role.setUsers(users);
                    //1.2 组包
                    ReqMsg reqMsg = Encode.encodeToMsg(role, SysBizTypeConstant.ROLE_CALL_Off_COR);
                    byte[] reqBytes = reqMsg.toBytes();
                    try {
                        //1.3 组网
                        Socket socket = new Socket(ServerInfo.IP, ServerInfo.PORT);
                        //1.4 发送
                        OutputStream out = socket.getOutputStream();
                        out.write(reqBytes);
                        out.flush();
                        //1.5 响应
                        //1.5.1 读取
                        InputStream in = socket.getInputStream();
                        List<byte[]> respBytes = NetWorkUtils.receive(in);
                        //1.5.2 关闭资源
                        in.close();
                        out.close();
                        socket.close();

                        //处理响应
                        byte[] respByte = ArrayUtils.joinBytes(respBytes);
                        RespMsg respMsg = RespMsg.toRespMsg(respByte);
                        Short status = respMsg.getStatus();
                        if (status.equals(RespMsg.NETWORK_STATUS_NORMAL)) {
                            //2.重新渲染界面（页不动的情况下）
                            //获取对应事件
                            LoseTrackUserAndRole loseTrackUserAndRole = getLoseTrackUserAndRole();
                            //获取用户列表界面
                            PageUserList pageUserList = loseTrackUserAndRole.getPageUserList();
                            pageUserList.getChildren().clear();//清除界面原有组件
                            pageUserList.uiInit();//重新初始化界面
                            pageUserList.loadAndRenderPage();//重新加载数据
                        }
                    } catch (IOException e) {
                        getLoseTrackUserAndRole().errorHint();
                    }
                });

                Button cancel = new Button("取消");
                hBox.getChildren().add(cancel);
                //事件
                cancel.setOnAction(event -> {
                    ButtonType buttonType = new ButtonType("");
                    alert.getDialogPane().getButtonTypes().add(buttonType);
                    alert.close();
                });
            }

            public LoseTrackUserAndRole getLoseTrackUserAndRole() {
                return loseTrackUserAndRole;
            }

            public void setLoseTrackUserAndRole(LoseTrackUserAndRole loseTrackUserAndRole) {
                this.loseTrackUserAndRole = loseTrackUserAndRole;
            }
        }


        public PageUserList getPageUserList() {
            return pageUserList;
        }

        public void setPageUserList(PageUserList pageUserList) {
            this.pageUserList = pageUserList;
        }

    }

    /**
     * 返回按钮事件
     */
    private static class CancelAction implements EventHandler {

        /**
         * 界面跳转信息
         */
        private PageSkipInfo pageSkipInfo;

        /**
         * 要返回的页数
         */
        private Integer srcCurrent;

        @Override
        public void handle(Event event) {
            //界面跳转（返回角色权限当前页）

            Page<Role> rolePage = new Page<>();
            rolePage.setCurrent(getSrcCurrent());
            NetWorkUtils.reqRolePagingPage(getPageSkipInfo(), rolePage);

        }


        public Integer getSrcCurrent() {
            return srcCurrent;
        }

        public void setSrcCurrent(Integer srcCurrent) {
            this.srcCurrent = srcCurrent;
        }

        public PageSkipInfo getPageSkipInfo() {
            return pageSkipInfo;
        }

        public void setPageSkipInfo(PageSkipInfo pageSkipInfo) {
            this.pageSkipInfo = pageSkipInfo;
        }
    }
}


